require "config/country_number.rb"

module CallcacheHelper
  def remove_dot(ip)
    return ip.gsub(".","_")
  end
  
  def get_annot(params)
    default = 3000
    if params[:annot] != nil
      begin
        value = Integer(params[:annot]) 
        return value 
      rescue
        return default
      end
    else
      return default
    end
    
    return default
  end
  
  def country_name(ccode)
    if COUNTRY_NUMBER.has_key?(ccode)
      return COUNTRY_NUMBER[ccode]["name"]
    else
      return "xxx-idk"
    end
  end
  
  def areacode(st)
    #puts st
    if !st.kind_of? String or st==nil
      return []
    end
    s = st.gsub("US-","").to_s
    numbers = []
    #puts "ssssssssssssssssssssssss" + s
    for a in AREA
      if a[1][0] == s
        
        numbers << a[0]
      end
    end # for
    return numbers
  end
end


